<?php
// +----------------------------------------------------------------------
// | 海豚PHP框架 [ DolphinPHP ]
// +----------------------------------------------------------------------
// | 版权所有 2016~2019 广东卓锐软件有限公司 [ http://www.zrthink.com ]
// +----------------------------------------------------------------------
// | 官方网站: http://dolphinphp.com
// +----------------------------------------------------------------------

namespace app\user\validate;

use think\Validate;

/**
 * 用户Vip扩展验证器
 * @package app\user\validate
 * @author 蔡伟明 <314013107@qq.com>
 */
class Vip extends Validate
{
    // 定义验证规则
    protected $rule = [
        'realname|姓名'   => 'require|length:1,18|chsAlpha',
        'mobile|手机号'	=> 'require|mobile',
		'idcard|身份证号码' => 'require|length:1,18',
//        'idcard|身份证号码' => 'require|idCard',
		'province|省份' => 'length:6',
		'city|城市' => 'length:6',
		'country|区县' => 'length:1,6',
		'address|地址' => 'length:6,32|chsAlphaNum',
		'postalcode|邮编' => 'length:6',
    ];

    // 定义验证提示
    protected $message = [
        'realname.require' => '请输入姓名',
		'mobile.mobile' => '手机号格式不正确',
		'province.require' => '请选择省份及城市',
		'city.require' => '请选择省份及城市',
		'address.require' => '请填写详细地址',
		'address.length' => '详细地址限制为6-32个字',
		'postalcode.require' => '请填写邮政编码',
    ];
	
	// 设置地址验证场景定义
	public function sceneAddress()
	{
		return $this->only(['province', 'city', 'country', 'address', 'postalcode'])
			->append('province', 'require')
			->append('city', 'require')
			// ->append('postalcode', 'require')
			->append('address', 'require|token');
	}    
}
